import { otherHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
import { GetOrderListParams, UpdateOrderParams } from './model/shopOrderModel';

enum Api {
  order = '/orders',
  logistics = '/kuaidi',
}

/**
 * @description: get order list api
 */
export function getOrderListApi(params: GetOrderListParams, mode: ErrorMessageMode = 'message') {
  return otherHttp.get<object | any>(
    {
      url: Api.order,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
/**
 * @description: get single order api
 */
export function getSingleOrderApi(
  params: { id: number | string },
  mode: ErrorMessageMode = 'message',
) {
  const { id } = params;
  return otherHttp.get<object | any>(
    {
      url: Api.order + `/${id}`,
    },
    {
      errorMessageMode: mode,
    },
  );
}
/**
 * @description: update order api
 */
export function updateOrderApi(params: UpdateOrderParams, mode: ErrorMessageMode = 'message') {
  const { id } = params;
  return otherHttp.put<object | any>(
    {
      url: Api.order + `/${id}`,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
/**
 * @description: test logistics api
 */
export function logisticsApi(params: { id: number | string }, mode: ErrorMessageMode = 'message') {
  const { id } = params;
  return otherHttp.get<object | any>(
    {
      url: Api.logistics + `/${id}`,
    },
    {
      errorMessageMode: mode,
    },
  );
}
